#include <stdio.h>
#include <stdlib.h>
#include "lab51.h" 

void insert(struct part invet[],int *num) {
    if(*num==MAX_PARTS)
    {
        printf("Database is full; cannot add more parts.\n");
        return;  
    }
    int part_number;
    printf("Enter part number: ");
    scanf("%d",&part_number);
    if(find_part(part_number,invet,*num)>=0) 
    {
        printf("Part already exists.\n");
        return;
    }

    int now = *num;

    invet[now].number = part_number;
    printf("Enter part name:");
    read_line(invet[now].name,NAME_LEN);
    printf("Enter quantity on hand");
    scanf("%d",&invet[now].on_hand);    
    now++;
    *num = now;
    return;
}